package com.oocl.batchdata.util;

import java.util.regex.Pattern;

public class StringValidator {

	public static boolean idValidate(String text) {
		return !Pattern.compile("[^0-9]").matcher(text).find();
	}

	public static boolean emailValidate(String text) {
		return Pattern.compile("^(\\w)+(\\.\\w+)*@(\\w)+((\\.\\w+)+)$")
				.matcher(text).find();
	}

	public static boolean sexValidate(String text) {
		return Pattern.compile("^(true|false)$").matcher(text).find();
	}

	public static boolean dateValidate(String text) {
		String regex1 = "^((19\\d{2})|(200\\d)|(201[0-7]))(?<sp>\\-|\\/)((0?[1-9])|(1[0-2]))(\\k<sp>)((0?[1-9])|([1-2]\\d)|(30))$";
//		String regex2 = "^((19\\d{2})|(200\\d)|(201[0-7]))-((0?[1-9])|(1[0-2]))-((0?[1-9])|([1-2]\\d)|(30))$";
		return Pattern.compile(regex1).matcher(text).find();
	}
}
